
% takes vessel selections done in batchTrackVasodilationVesselFill_v2_0 (or later),
% which can be done on one of the technical repeats, and copies them
% to the other technical repeats (e.g. 00001 copied to 00002 and 00003 in
% the origianl whisker stim paradigm or in the newer visual stim paradigm)
%%
function copyVesselSelectionsAcrossTrials

fn = dir('*_manualEndpointSelection.mat');
for n = 1:length(fn)
    load(fn(n).name);
    originalMovie = movname;
    ind = strfind(fn(n).name,'_manualEndpointSelection');
    rootstring = fn(n).name(1:(ind-3));
    otherRepeats = dir([rootstring,'*.tif']);
    for n2 = 1:length(otherRepeats)
        if ~strcmp(originalMovie,otherRepeats(n2).name)
            curname = strrep(otherRepeats(n2).name,'.tif','_manualEndpointSelection.mat');
            if ~isfile(curname)
                movname = otherRepeats(n2).name;
                save(curname,'ep1','ep2','endpointIDs','movname')
            end
        end
    end
    clear ep1 ep2 endpointIDs movname
end